# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>

pkgbase=libsigc++
pkgname=(
  libsigc++
  libsigc++-docs
)
pkgver=2.12.1
pkgrel=1
pkgdesc="Callback Framework for C++"
url="https://libsigcplusplus.github.io/libsigcplusplus/"
arch=(loong64 x86_64)
license=(LGPL)
depends=(gcc-libs)
makedepends=(
  git
  meson
  mm-common
)
options=(!emptydirs)
_commit=6bef4e0005f00f0844d917866aec7e3b2d829fdf  # tags/2.12.1^0
source=("git+https://github.com/libsigcplusplus/libsigcplusplus#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd libsigcplusplus
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd libsigcplusplus
}

build() {
  local meson_options=(
    -D maintainer-mode=true
  )

  arch-meson libsigcplusplus build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

# Do not remove the space before the () or commitpkg will
# accidentally to run this function on the system (!!!) 
package_libsigc++ () {
  provides=(
    "libsigc++2.0=$pkgver"
    libsigc-2.0.so
  )
  conflicts=(libsigc++2.0)
  replaces=(libsigc++2.0)

  meson install -C build --destdir "$pkgdir"

  # Split -docs
  mkdir -p docs/usr/share
  mv -t docs/usr/share "$pkgdir"/usr/share/{devhelp,doc}
}

package_libsigc++-docs() {
  pkgdesc+=" (documentation)"
  depends=()
  provides=("libsigc++2.0-docs=$pkgver")
  conflicts=(libsigc++2.0-docs)
  replaces=(libsigc++2.0-docs)
  options=(!strip)

  mv -t "$pkgdir" docs/*
}
